#!/usr/bin/env python

PREFIX_STATICS = ''
PREFIX_NO_STATICS = ''

JOB_ID = '||job_id:%s||'


# common
DB_C = PREFIX_NO_STATICS + 'db'
DB_C_J = DB_C + JOB_ID
LC = PREFIX_NO_STATICS + 'looping_call'
LC_J = LC + JOB_ID
JBB_CONS = 'job_id:<{}>-name_first:<{}>-name_second:<{}>'

# framework
WORKER_INIT = PREFIX_NO_STATICS + 'worker_init'
WORKER_INIT_ERR = PREFIX_NO_STATICS + 'worker_init_error'
WORKER_START_SPIDER = PREFIX_NO_STATICS + 'start_spider'
WORKER_START_SPIDER_ERR = PREFIX_NO_STATICS + 'start_spider_error'
WORKER_START_PARSER = PREFIX_NO_STATICS + 'start_parser'
WORKER_START_PARSER_ERR = PREFIX_NO_STATICS + 'start_parser_error'
WORKER_JOB_CHK = PREFIX_NO_STATICS + 'job_check'
WORKER_SLV_CONN = PREFIX_NO_STATICS + 'slave_connected'
WORKER_SLV_LOST = PREFIX_NO_STATICS + 'slave_lost'
WORKER_SLV_REG = PREFIX_NO_STATICS + 'slave_register'
WORKER_SLV_REG_ERR = PREFIX_NO_STATICS + 'slave_register_error'
WORKER_MSG = PREFIX_NO_STATICS + 'message'

# spider
SPIDER_INIT_J = PREFIX_NO_STATICS + 'spider_init' + JOB_ID
SPIDER_INIT_ERR_J = PREFIX_NO_STATICS + 'spider_init_error' + JOB_ID
SPIDER_IDLE_J = PREFIX_NO_STATICS + 'spider_idle' + JOB_ID
SPIDER_CLOSE_J = PREFIX_NO_STATICS + 'spider_closed' + JOB_ID
CRAWL_STAT_S_J = PREFIX_NO_STATICS + 'crawl_statics' + JOB_ID
CRAWL_ERR_J = PREFIX_NO_STATICS + 'crawl_error' + JOB_ID
CRAWL_SUC_J = PREFIX_STATICS + 'crawl_success' + JOB_ID
RESP_GET_J = PREFIX_NO_STATICS + 'response_get' + JOB_ID
RESP_ERR_J = PREFIX_NO_STATICS + 'response_error' + JOB_ID
RESP_PAK_J = PREFIX_NO_STATICS + 'response_packed' + JOB_ID
ITM_SAVE_SUC_J = PREFIX_NO_STATICS + 'item_save_success' + JOB_ID
ITM_SAVE_ERR_J = PREFIX_NO_STATICS + 'item_save_error' + JOB_ID

# parse
PARSER_INIT_J = PREFIX_NO_STATICS + 'parser_init' + JOB_ID
PARSER_INIT_ERR_J = PREFIX_NO_STATICS + 'parser_init_error' + JOB_ID
PARSER_CLOSE_J = PREFIX_NO_STATICS + 'parser_close' + JOB_ID
PARSE_GET_SOURCE_J = PREFIX_NO_STATICS + 'get_source' + JOB_ID
PARSE_GET_SOURCE_ERR_J = PREFIX_NO_STATICS + 'get_source_error' + JOB_ID
PARSE_STAT_S_J = PREFIX_STATICS + 'parse_statics' + JOB_ID
PARSE_SUC_J = PREFIX_NO_STATICS + 'parse_success' + JOB_ID
PARSE_ERR_J = PREFIX_NO_STATICS + 'parse_error' + JOB_ID
PARSE_WRN_J = PREFIX_NO_STATICS + 'parse_warn' + JOB_ID
PARSE_SAVE_J = PREFIX_NO_STATICS + 'parse_save' + JOB_ID
PARSE_CHK_SUC_J = PREFIX_NO_STATICS + 'parse_check_success' + JOB_ID
PARSE_CHK_ERR_J = PREFIX_NO_STATICS + 'parse_check_error' + JOB_ID

# middleware
#  user agent change
MDW_UAC_J = PREFIX_NO_STATICS + 'UA' + JOB_ID
MDW_INIT = PREFIX_NO_STATICS + 'middleware_init'

# phantomjs
PHANTOMJS_REQ_J = PREFIX_NO_STATICS + 'phantomjs_request' + JOB_ID
PHANTOMJS_FAILED_J_EXCEED_MAX = PREFIX_NO_STATICS + 'phantomjs_error||job_id:%s,reason:empty_or_invalid_status'
PHANTOMJS_RETRY_J = PREFIX_NO_STATICS + 'phantomjs_retry' + JOB_ID
PHANTOMJS_SUC_J = PREFIX_NO_STATICS + 'phantomjs_success' + JOB_ID
PHANTOMJS_FAILED_J_UNKNOWN = PREFIX_NO_STATICS + 'phantomjs_error||job_id:%s,reason:unknown'

# change proxy
PROXY_C_J = 'proxy_change' + JOB_ID
PROXY_G_SUC_J = 'proxy_get_success' + JOB_ID
PROXY_G_ERR_J = 'proxy_get_error' + JOB_ID
PROXY_R_SUC_J = 'proxy_request_success' + JOB_ID
PROXY_R_ERR_J = 'proxy_request_error' + JOB_ID

# captcha TODO

# DB
FLUME_WR_SUC = PREFIX_NO_STATICS + 'flume_success' + JOB_ID
FLUME_WR_ERR = PREFIX_NO_STATICS + 'flume_error' + JOB_ID

# External API
EXTERNAL_API_SUC = PREFIX_NO_STATICS + 'external_api_success' + JOB_ID
EXTERNAL_API_ERR = PREFIX_NO_STATICS + 'external_api_error' + JOB_ID

# Website monitor
WEBSITE_M_CHANGE_J = PREFIX_NO_STATICS + 'website_change' + JOB_ID

# Proxy monitor
PROXY_M_GET_ERR_J = PREFIX_NO_STATICS + 'proxy_get_emtpy' + JOB_ID

# Website total count monitor
WEBSITE_TC_MONITOR_J = PREFIX_NO_STATICS + 'website_total_count' + JOB_ID